﻿/**
 * Copyright 2019-2020 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef INC_TDT_STATUS_H_
#define INC_TDT_STATUS_H_

#include <stdio.h>

#ifdef __cplusplus
#include <map>
#include <mutex>
#include <string>
#include <vector>
#else
#include <stdint.h>
#endif

#ifdef __cplusplus
using TDT_StatusT = uint32_t;
#else
typedef uint32_t TDT_StatusT;
#endif

#ifndef TDT_LIB_EXPORT
#define TDT_LIB_EXPORT __attribute__((visibility("default")))
#endif
/**
 * @ingroup  tdt status.
 *
 * Tdt debug level
 */
enum {
  TDT_DEBUG = 0,   /**< Debug*/
  TDT_INFO = 1,    /**< Info*/
  TDT_WARNING = 2, /**< Warning*/
  TDT_ERROR = 3,   /**< Error*/
  TDT_FATAL = 4,   /**< Fatal*/
  TDT_EVENT = 5,   /**< Event*/
  TDT_OPLOG = 6,   /**< Oplog*/
  TDT_TRACE = 7    /**< Trace*/
};

enum {
  TDT_OK_CODE = 0,
  TDT_DEBUG_INFO_CODE,
  TDT_INTERNAL_ERROR_CODE,
  TDT_COMMON_WARNING_CODE,
  TDT_PREFETCH_STOPED_CODE,
  TDT_FILE_SIZE_TOO_LARGE_CODE,
  TDT_FILE_INVALID_PATH_CODE,
  TDT_MEMORY_EXHAUSTED_CODE,
  TDT_INTERGER_REVERSED_CODE,
  TDT_FILE_NOT_EXIST_CODE,
  TDT_DEFAULT_CONFIG_FILE_NOT_EXIST_CODE,
  TDT_INSTANCE_NOT_INITIALED_CODE,
  TDT_INITIAL_FAILED_CODE,
  TDT_INSTANCE_NOT_FOUND_CODE,
  TDT_HDC_CREATE_SESSION_FAILED_CODE,
  TDT_HDC_DESTROY_SESSION_FAILED_CODE,
  TDT_HDC_SESSION_DO_NOT_EXIST_CODE,
  TDT_PID_IS_EXIST_CODE,
  TDT_HDC_SRV_INIT_ERROR_CODE,
  TDT_HDC_SRV_CREATE_ERROR_CODE,
  TDT_HDC_SRV_DESTROY_ERROR_CODE,
  TDT_HDC_SRV_ACCEPT_ERROR_CODE,
  TDT_HDC_SRV_CLOSED_ERROR_CODE,
  TDT_HDC_INTERNAL_ERROR_CODE,
  TDT_HDC_INFO_CODE,
  TDT_HDC_SEND_ERROR_CODE,
  TDT_MESSAGE_PARSE_ERROR_CODE,
  TDT_HDC_SEG_SIZE_ERROR_CODE,
  TDT_HDC_MESSAGE_NULL_CODE,
  TDT_HDC_SEARFUNC_IS_NULL_CODE,
  TDT_HDC_SENDMSG_FAILED_CODE,
  TDT_HDC_SRV_CLOSE_CHILD_SESSION_ERROR_CODE,
  TDT_HDC_SRV_CLOSE_SERVER_SESSION_ERROR_CODE,
  TDT_HDC_SRV_HEART_BEAT_TIMEOUT_CODE,  // 30
  TDT_HDC_DRV_ERROR_CODE,
  TDT_HDC_SERVER_CLIENT_SOCKET_CLOSED_CODE,
  TDT_TSD_START_FAIL_CODE,
  TDT_TSD_CLEANPROC_FIRST_GETPID_FAILED_CODE,
  TDT_TSD_CLEANPROC_KILL_PROCESS_FAILED_CODE,
  TDT_TSD_CLEANPROC_SECOND_GETPID_FAILED_CODE,
  TDT_TSD_CLEANPROC_FINAL_FAILED_CODE,
  TDT_TSD_INIT_STATE_FAILED_CODE,
  TDT_TSD_INIT_HDCSERVER_FAILED_CODE,
  TDT_TSD_SEND_HEARTBEAT_FAILED_CODE,
  TDT_TSD_CLEAN_RESOURCE_FAILED_CODE,
  TDT_TSD_SEND_MSG_FAILED_CODE,
  TDT_TSD_AICPU_SD_PROCESS_ABNORMAL_CODE,
  TDT_TSD_CUSTOM_PROCESS_ABNORMAL_CODE,
  TDT_PPC_DRIVER_INIT_FAIL_CODE,
  TDT_PPC_SERVER_CLIENT_CREATE_FAIL_CODE,
  TDT_PPC_SERVER_CLIENT_DESTORY_FAIL_CODE,
  TDT_PPC_SERVER_CLOSE_CODE,
  TDT_PPC_GET_SET_MSG_BUFFER_FAIL_CODE,
  TDT_PPC_SESSION_CONNECT_FAIL_CODE,  // 40
  TDT_PPC_SESSION_NOT_EXISTED_CODE,
  TDT_PPC_SEND_RECEIVE_MSG_FAIL_CODE,
  TDT_PPC_MSG_FREE_FAIL_CODE,
  TDT_PPC_ALLOC_MSG_FAIL_CODE,
  TDT_PPC_MSG_LEN_NOT_MATCH_CODE,
  TDT_PPC_MSG_BUF_NULL_CODE,
  TDT_PPC_CLIENT_INVALID_PARAM_CODE,
  TDT_PPC_SERVER_INVALID_PARAM_CODE,
  TDT_PPC_CLIENT_RECVDATA_CONTINUE_CODE,
  TDT_PPC_SERVER_CLIENT_SOCKET_CLOSED_CODE,  // 50
  TDT_PPC_RECV_MSG_ERROR_CODE,
  TDT_PPC_SESSION_CLOSE_ERROR_CODE,
  TDT_SHUFFLE_SHUFFLE_SIZE_ILLEGAL_CODE,
  TDT_SHUFFLE_ONLINE_UNIQUE_SEED_ILLEGAL_CODE,
  TDT_SHUFFLE_UNABLE_TO_CREATE_SHUFFLE_LIST_CODE,
  TDT_SHUFFLE_ILLEGAL_SHUFFLE_TYPE_CODE,
  TDT_PREFETCH_ILLEGAL_DATATYPE_CODE,
  TDT_SUPERVISOR_UNKOWN_JOB_STATE_CODE,
  TDT_MAP_BUFFER_ERROR_CODE,
  TDT_ALLOC_BUFFER_FAILED_CODE,
  TDT_FREE_HDC_BUFFER_FAILED_CODE,
  TDT_DATA_SIZE_WRONG_CODE,
  TDT_MEMORY_POOL_INITED_CODE,
  TDT_SENDMSG_FAILED_CODE,
  TDT_INVALID_VALUE_CODE,
  TDT_NO_USEFUL_MEMORY_CODE,
  TDT_MESSAGE_NULL_CODE,
  TDT_MEMORY_POOL_STOPPED_CODE,
  TDT_HDC_MEMORY_ADDR_NOT_ALIGN_CODE,
  TDT_MEMORY_POOL_GET_NULL_CODE,
  TDT_MEMORY_POOL_NOT_EXISTED_CODE,
  TDT_RECOVER_DATA_FAILED_CODE,
  TDT_MEMORY_STATUS_ERROR_CODE,
  TDT_MEMORY_POOL_UPDATE_FAILED_CODE,
  TDT_MEMORY_POOL_RESIZE_FAILED_CODE,
  TDT_MEMORY_DESTROY_FAILED_CODE,
  TDT_EXCEED_MAX_THREAD_CODE,
  TDT_WARNING_SET_THREAD_NAME_FAILED_CODE,
  TDT_WRONG_PRIORITY_CODE,
  TDT_JOIN_TASK_ERROR_CODE,
  TDT_NULL_FUNC_CODE,
  TDT_INIT_FAIL_CODE,
  TDT_EXISTED_FUNC_CODE,
  TDT_FILE_GET_FILE_STATE_FAIL_CODE,
  TDT_FILE_OPEN_FILE_FAIL_CODE,
  TDT_FILE_FILE_DESTROYED_CODE,
  TDT_FILE_UNABLE_TO_GET_FILE_MEMORY_CODE,
  TDT_PREFETCH_UNABLE_TO_GET_TDTDATAITEM_CODE,
  TDT_HDCSERVER_DO_NOT_EXIST_CODE,
  TDT_HDCSESSIONID_NOT_AVAILABLE_CODE,
  TDT_SET_HDCSESSION_REFERENCE_FAILED_CODE,
  TDT_HDC_RECV_MSG_ERROR_CODE,
  TDT_HDC_SEND_MSG_ERROR_CODE,
  TDT_FILE_CONTENT_EMPTY_CODE,
  TDT_TDTSEVER_ACCEPT_FAILED_CODE,
  TDT_CHANNEL_DO_NOT_EXIST_CODE,
  TDT_NULL_POINTER_MSG_CODE,
  TDT_TRAN_UNKNOWN_RSP_CODE,
  TDT_TRAN_TIMEOUT_CODE,
  TDT_TRAN_NOT_EXIST_CODE,
  TDT_TRAN_ID_GEN_ERROR_CODE,
  TDT_SEND_CHANNEL_FAILED_CODE,
  TDT_SEND_CHANNEL_TIMEOUT_CODE,
  TDT_QUEUE_STOPPED_CODE,
  TDT_QUEUE_POP_FAILED_CODE,
  TDT_QUEUE_PUSH_FAILED_CODE,
  TDT_QUEUE_NOT_FIND_CODE,
  TDT_QUEUE_CREATE_FAILED_CODE,
  TDT_QUEUE_FULL_CODE,
  TDT_QUEUE_EMPTY_CODE,
  TDT_DATA_ENTO_CP_FAILED_CODE,
  TDT_STOP_CP_QUEUE_FAILED_CODE,
  TDT_RECV_MSG_NO_CHANNEL_INFO_ERROR_CODE,
  TDT_CHANNEL_HAS_NO_SESSION_ERROR_CODE,
  TDT_PREFETCH_SAMPLE_HAS_NO_LABEL_CODE,
  TDT_HDC_CLIENT_INIT_ERROR_CODE,
  TDT_HDC_CLIENT_CREATE_SESSION_ERROR_CODE,
  TDT_HDC_CLIENT_DO_NOT_EXIST_CODE,
  TDT_HDC_CLIENT_DESTROY_ERROR_CODE,
  TDT_BIND_CPUCORE_FAILED_CODE,
  TDT_HDC_CLIENT_CLOSED_CODE,
  TDT_HDC_SRV_CLOSED_CODE,
  TDT_HDC_SRV_TYPE_ERROR_CODE,
  TDT_TSD_CLT_OPEN_FAILED_CODE,
  TDT_TSD_CLT_CLOSE_FAILED_CODE,
  TDT_TSD_CLT_UPDATE_PROFILING_FAILED_CODE,
  TDT_TSD_CLT_INTERFACE_NOT_SUPPORT_CODE,
  TDT_SUPERVISOR_ILLEGAL_HEARTBEAT_TIME_CODE,
  TDT_SUPERVISOR_INOTIFY_READ_SIZE_ERROR_CODE,
  TDT_SUPERVISOR_INOTIFY_INTERRUPT_CODE,
  TDT_SUPERVISOR_INOTIFY_INIT_ERROR_CODE,
  TDT_SUPERVISOR_CLOSE_INOTIFYFD_FAIL_CODE,
  TDT_SUPERVISOR_INOTIFY_WATCH_ERROR_CODE,
  TDT_TRANSFER_CANNOT_OPEN_CONFIGFILE_CODE,
  TDT_TRANSFER_PARSE_FILE_FAILED_CODE,
  TDT_TRANSFER_NO_CHANNEL_DATA_CODE,
  TDT_PREFETCH_CREATE_FAILED_CODE,
  TDT_TRANSFER_NO_PARAMETER_CODE,
  TDT_TRANSFER_NO_PARAMETER_ARG_CODE,
  TDT_FILE_TYPE_UNSUPPORT_CODE,
  TDT_FILE_DIR_IS_NULL_CODE,
  TDT_FILE_GET_DIR_TREE_ERROR_CODE,
  TDT_FILE_CANNOT_OPEN_DIR_CODE,
  TDT_PREFETCH_SAMPLE_CANNOT_BE_READ_CODE,
  TDT_PREFETCH_DATA_QUEUE_IS_CLOSED_CODE,
  TDT_PREFETCH_GET_SHUFFLE_RESULT_FAIL_CODE,
  TDT_FILE_CANNOT_DFREE_FILE_MEMORY_CODE,
  TDT_TRANSFER_CREATE_DELIVER_FAILED_CODE,
  TDT_TRANSFER_TRAIN_DATA_DELIVER_IS_NULLPTR_CODE,
  TDT_TRANSFER_EMPTY_GROUPNAME_IN_MULTI_GROUPS_CODE,
  TDT_TRANSFER_DUPLICATE_GROUPNAME_CODE,
  TDT_TRANSFER_DUPLICATE_DEVICE_CODE,
  TDT_TRANSFER_FIND_DEVICE_FAIL_CODE,
  TDT_SUPERVISOR_FAIL_TO_WRITE_PID_FILE_CODE,
  TDT_SUPERVISOR_HEARTBEAT_FILE_NOT_INITED_CODE,
  TDT_SUPERVISOR_JOB_COMMAND_FILE_NOT_INITED_CODE,
  TDT_SUPERVISOR_JOB_STATE_FILE_NOT_INITED_CODE,
  TDT_PREFETCH_LABEL_FILE_NOT_INITED_CODE,
  TDT_PREFETCH_SAMPLE_FILE_DIR_NOT_INITED_CODE,
  TDT_PREFETCH_NOT_INITED_CODE,
  TDT_PREFETCH_SHUFFLER_NOT_CREATED_CODE,
  TDT_SHUFFLE_NOT_INITED_CODE,
  TDT_PREFETCH_SHUFFLED_ITEM_OUT_OF_FILE_LIST_CODE,
  TDT_TRANSFER_INIT_FAILED_CODE,
  TDT_TRANSFER_START_FAILED_CODE,
  TDT_FOLDER_CANNOT_BE_CREATED_CODE,
  TDT_CANNOT_GET_STAT_OF_FOLDER_CODE,
  TDT_FOLDER_IS_FILE_CODE,
  TDT_TRANSFER_CONFIG_FIEL_SYNTAX_ERROR_CODE,
  TDT_CHECKSUM_ILLEGAL_MD5_PARAM_CODE,
  TDT_CHECKSUM_MD5_INIT_FAILED_CODE,
  TDT_CHECKSUM_MD5_UPDATE_FAILED_CODE,
  TDT_CHECKSUM_MD5_FINAL_FAILED_CODE,
  TDT_TRANSFER_DELIVER_IS_NONE_CODE,
  TDT_SUPERVISOR_FAIL_TO_DEL_JOB_CMD_FILE_CODE,
  TDT_TRANSFER_FAIL_TO_GET_ENV_VARIABLE_CODE,
  TDT_MONITOR_INOTIFY_INIT_ERROR_CODE,
  TDT_MONITOR_INOTIFY_WATCH_ERROR_CODE,
  TDT_MONITOR_CLOSE_INOTIFYFD_FAIL_CODE,
  TDT_MONITOR_INOTIFY_READ_SIZE_ERROR_CODE,
  TDT_MONITOR_UNSUPPORT_CFGITEM_CODE,
  TDT_MONITOR_FAIL_TO_SET_CFGITEM_CODE,
  TDT_MONITOR_READ_FILE_FAIL_CODE,
  TDT_MONITOR_CONFIG_FILE_FORMAT_ERROR_CODE,
  TDT_MONITOR_STRCAT_FAILED_CODE,
  TDT_MONITOR_CREATE_CONFIG_FILE_FAIL_CODE,
  TDT_PREFETCH_FAIL_TO_GENERATE_MD5_CODE,
  TDT_RECV_MSG_MD5_WRONG_CODE,
  TDT_RECV_MSG_FAIL_TO_GENERATE_MD5_CODE,
  TDT_RECV_MSG_SEQUENCE_ERROR_CODE,
  TDT_SERVER_MEMORY_COPY_FAILED_CODE,
  TDT_DEVICEID_ERROR_CODE,
  TDT_MEMORY_DATA_TYPE_FACTORY_MAKE_SHARED_FAILED_CODE,
  TDT_PREFETCH_FILELIST_NOT_EXIST_CODE,
  TDT_PREFETCH_SAMPLE_FILE_NOT_FOUND_CODE,
  TDT_PREFETCH_FILE_OPEN_FAIL_CODE,
  TDT_PREFETCH_FILE_STAT_FAIL_CODE,
  TDT_PREFETCH_FILE_MMAP_FAIL_CODE,
  TDT_PREFETCH_FILE_UNMAP_FAIL_CODE,
  TDT_PREFETCH_FILE_CLOSE_FAIL_CODE,
  TDT_PREFETCH_FILE_PARSE_FAIL_CODE,
  TDT_PREFETCH_CRC32_SIZE_FAIL_CODE,
  TDT_PREFETCH_CRC32_DATA_FAIL_CODE,
  TDT_PREFETCH_DATA_QUEUE_CLOSED_CODE,
  TDT_PREFETCH_INITIALIZE_FAILED_CODE,
  TDT_PREFETCH_MAP_INSERT_FAILED_CODE,
  TDT_PREFETCH_INVALID_FILELIST_LINE_CODE,
  TDT_FILE_STRINGSTREAM_TO_VALUE_FAILED_CODE,
  TDT_LIST_ID_OFFSET_LENGTH_POSITIVE_INTEGER_FAILED_CODE,
  TDT_SHUFFLE_ILLEGAL_SHUFFLE_PARAM_CODE,
  TDT_FILE_SHUFFLER_CREATE_FAILED_CODE,
  TDT_FILE_UPLOADER_CREATE_FAILED_CODE,
  TDT_FILE_DOWNLOADER_CREATE_FAILED_CODE,
  TDT_OBS_CONFIG_INFORMATION_FAIL_CODE,
  TDT_OBS_CALLBACK_ARGUMENT_FAIL_CODE,
  TDT_OBS_DOWNLOAD_CREATE_THREAD_FAILED_CODE,
  TDT_OBS_DOWNLOAD_FILE_FAIL_CODE,
  TDT_OBS_DOWNLOAD_INIT_FAIL_CODE,
  TDT_OBS_DOWNLOAD_METADATA_FAIL_CODE,
  TDT_OBS_LIST_BUCKET_OBJECTS_FAIL_CODE,
  TDT_MEMORY_MEMCPY_FAILED_CODE,
  TDT_MEMORY_MEMSET_FAILED_CODE,
  TDT_MKDIR_CMD_FAILED_CODE,
  TDT_CP_CMD_FAILED_CODE,
  TDT_HOST_INIT_FAILED_CODE,
  TDT_HOST_CHANNEL_NAME_EMPTY_CODE,
  TDT_HOST_ALLOCATE_MEMORY_FAILED_CODE,
  TDT_HOST_MEMORY_COPY_FAILED_CODE,
  TDT_HOST_UNABLE_GET_TDTDATAELEM_CODE,
  TDT_HOST_PUSH_NOT_INIT_CODE,
  TDT_TUNING_DATA_TRANSFER_INIT_FAILED_CODE,
  TDT_TUNING_DATA_RECEIVE_CHECK_PARA_ERROR_CODE,
  TDT_TUNING_DATA_TRANSFER_PARAMETER_ERROR_CODE,
  TDT_RECV_MSG_CHECKSUM_WRONG_ERROR_CODE,
  TDT_SVM_INIT_FAILED_CODE,
  TDT_SVM_FREE_PIN_FAILED_CODE,
  TDT_SVM_FREE_SVM_FAILED_CODE,
  TDT_SVM_ADD_BUFFER_MAP_FAILED_CODE,
  TDT_STATUS_CODE_TOTAL
};

/**
 * @ingroup Tdt status
 * @brief Regiter error code
 * @param moduleId [IN] Module ID
 * @param logLevel [IN] Log level
 * @param CODE_NAME [out] Error name
 * @param codeDesc [IN] Error description
 */
#ifdef __cplusplus
#define TDT_DEF_ERROR_CODE(moduleId, logLevel, CODE_NAME, codeDesc)                                          \
  constexpr TDT_StatusT CODE_NAME = ((0xFFFF & ((uint16_t)moduleId)) << 16) |                                \
                                    (0xF000 & (((uint16_t)logLevel) << 12)) | (0x0FFF & (CODE_NAME##_CODE)); \
  const tdt::ErrorNoRegisterar g_##CODE_NAME##_errorno(CODE_NAME, codeDesc);
#else
#define TDT_DEF_ERROR_CODE(moduleId, logLevel, CODE_NAME, codeDesc) \
  static const TDT_StatusT CODE_NAME =                              \
      ((0xFFFF & ((uint16_t)moduleId)) << 16) | (0xF000 & (((uint16_t)logLevel) << 12)) | (0x0FFF & CODE_NAME##_CODE);
#endif

/**
 * @ingroup Tdt status
 * @brief Get error level according error name
 * @param CODE_NAME [IN] Error code
 * @param codeDesc [OUT] Error description
 */
#define TDT_GET_ERROR_LEVEL(CODE_NAME) ((CODE_NAME & 0x0000F000) >> 12)

#ifdef __cplusplus
#define TDT_GET_ERROR_STR(CODE_NAME) (tdt::StatusFactory::GetInstance()->GetErrDesc(CODE_NAME))
#endif

// Register module id: 0xAABB, AA means system level number, BB means module level number
constexpr uint16_t MODID_TDT_CLIENT = 0x0101; // TDT_CLIENT module ID
constexpr uint16_t MODID_TSD_SERVER = 0x0102; // TSD_SERVER
constexpr uint16_t MODID_HDC = 0x0103; // HDC_SERVER
constexpr uint16_t MODID_TDT_SHUFFLE = 0x0104; // TDT shuffle module ID
constexpr uint16_t MODID_TDT_PREFETCH = 0x0105; // TDT prefetch module ID
constexpr uint16_t MODID_TDT_TRANSFER = 0x0106; // TDT TrainDataTransfer module ID
constexpr uint16_t MODID_TDT_SUPERVISOR = 0x0107; // TDT supervisor模块ID
constexpr uint16_t MODID_MEM_POOL = 0x0108; // MEMORY_POOL
constexpr uint16_t MODID_PPC = 0x0109; // TDT PPC
constexpr uint16_t MODID_TDT_FILE = 0x0110; // TDT file operation module ID
constexpr uint16_t MODID_HDC_SERVER = 0x0111; // HDC_SERVER module ID
constexpr uint16_t MODID_TDT_SERVER = 0x0112; // TDTServer module ID
constexpr uint16_t MODID_HDC_CLIENT = 0x0113; // HDC_CLIENT module ID
constexpr uint16_t MODID_TSD_CLIENT = 0x0114; // TSD_CLIENT module ID
constexpr uint16_t MODID_CHECKSUM = 0x0115; // Checksum module ID
constexpr uint16_t MODID_TDT_MONITOR = 0x0116; // TDT monitor module ID
constexpr uint16_t MODID_TDT_HOST = 0x0117; // GE adapts the TDT HOST module ID
constexpr uint16_t MODID_SVM = 0x0118; // SVM Driver module ID

constexpr uint32_t TDT_API_MAX_SUB_VERSION = 100;
static const int32_t TDT_INVAILED_DEVICE_ID = 0xFFFFFFFF;

typedef enum tdt_api_version {
  TDT_API_VERSION_V1_00 = 100,
  TDT_API_VERSION_V1_01 = 101,
  TDT_API_VERSION_V2_00 = 200
} TDT_API_VERSION;

#ifdef __cplusplus
namespace tdt {
class StatusFactory {
 public:
  /**
  * @ingroup hiaiengine
  * @brief Get a pointer to StatusFactory
  * @param [in]:
  * @return StatusFactory pointer
  */
  TDT_LIB_EXPORT static StatusFactory *GetInstance();

  /**
  * @ingroup hiaiengine
  * @brief Registration error code
  * @param [in]err error code
  * @param [in]desc Description string of the error code
  */
  TDT_LIB_EXPORT void RegisterErrorNo(const uint32_t err, const std::string &desc);

  /**
  * @ingroup hiaiengine
  * @brief Get error code description string
  * @param [in]err error code
  */
  std::string GetErrDesc(const uint32_t err);

  /**
  * @ingroup hiaiengine
  * @brief Static function: Get error code description string
  * @param [in]err error code
  * return : If there is a problem, return the empty string ""
  */
  static std::string GetErrCodeDesc(uint32_t errCode);

 protected:
  /**
  * @ingroup hiaiengine
  * @brief Constructor
  * @param [in] void
  */
  StatusFactory();

  /**
  * @ingroup hiaiengine
  * @brief Destructor
  * @param [in] void
  */
  ~StatusFactory() {}

  StatusFactory(const StatusFactory &) = delete;
  StatusFactory(StatusFactory &&) = delete;
  StatusFactory &operator=(const StatusFactory &) = delete;
  StatusFactory &operator=(StatusFactory &&) = delete;

  static std::mutex &GetMutex();

 private:
  std::mutex rwMutex_;
  std::map<uint32_t, std::string> errDesc_;
};

class ErrorNoRegisterar {
 public:
  /**
  * @ingroup hiaiengine
  * @brief Registration error code
  * @param [in]err error code
  * @param [in]desc Description of the registration error code
  */
  ErrorNoRegisterar(const uint32_t &err, const std::string &desc) {
    StatusFactory::GetInstance()->RegisterErrorNo(err, desc);
  }

  ~ErrorNoRegisterar() {}
  ErrorNoRegisterar(const ErrorNoRegisterar &) = delete;
  ErrorNoRegisterar(ErrorNoRegisterar &&) = delete;
  ErrorNoRegisterar &operator=(const ErrorNoRegisterar &) = delete;
  ErrorNoRegisterar &operator=(ErrorNoRegisterar &&) = delete;
};
}  // namespace tdt
#endif

// register error code
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_INFO, TDT_OK, "running ok");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_DEBUG, TDT_DEBUG_INFO, "debug info");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_INTERNAL_ERROR, "internal error");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_WARNING, TDT_COMMON_WARNING, "warnging");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_INFO, TDT_PREFETCH_STOPED, "stopped");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_FILE_NOT_EXIST, "File is not existed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_DEFAULT_CONFIG_FILE_NOT_EXIST, "Default config file not exist");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_FILE_SIZE_TOO_LARGE, "file size is too large");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_FILE_INVALID_PATH, "file path is invalid");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_MEMORY_EXHAUSTED, "memory exhausted error");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_INTERGER_REVERSED, "interger reached reverse");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_INSTANCE_NOT_INITIALED,
                   "call member function before instance initialed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_INITIAL_FAILED, "initial failed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_INSTANCE_NOT_FOUND, "instance not found");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_HDC_CREATE_SESSION_FAILED, "create hdc session failed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_HDC_DESTROY_SESSION_FAILED, "destory hdc session failed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_HDC_SESSION_DO_NOT_EXIST, "hdc session id do not exist");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_PID_IS_EXIST, "tdtMain pid is exist");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SRV_INIT_ERROR, "hdc server init error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SRV_CREATE_ERROR, "hdc server create error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SRV_DESTROY_ERROR, "hdc server destroy error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SRV_ACCEPT_ERROR, "hdc server accept error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SRV_CLOSED_ERROR, "hdc server closed error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_INTERNAL_ERROR, "hdc fail");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_DEVICEID_ERROR, "hdc device id error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SRV_CLOSE_CHILD_SESSION_ERROR, "hdc server close child session error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SEARFUNC_IS_NULL, "serarfunc is null");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SENDMSG_FAILED, "hdc send msg failed");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SRV_CLOSE_SERVER_SESSION_ERROR,
                   "hdc server close server session error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SRV_HEART_BEAT_TIMEOUT, "hdc server heart beat timeout");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_DRV_ERROR, "hiai drv return error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_INFO, TDT_HDC_INFO, "hdc info");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SEND_ERROR, "hdc send message failed");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_SEG_SIZE_ERROR, "hiai seg size error");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_HDC_MESSAGE_NULL, "Message input is null");
TDT_DEF_ERROR_CODE(MODID_HDC, TDT_ERROR, TDT_MESSAGE_PARSE_ERROR, "hdc message parse error");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDCSERVER_DO_NOT_EXIST, "hdc server do not exist");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDCSESSIONID_NOT_AVAILABLE, "hdc sessionid vector is empty");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_SET_HDCSESSION_REFERENCE_FAILED,
                   "hdc set hdc session reference failed");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDC_RECV_MSG_ERROR, "hdc recv message failed");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDC_SEND_MSG_ERROR, "hdc send message failed");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDC_SRV_TYPE_ERROR, "hdc service type is not supported");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDC_SERVER_CLIENT_SOCKET_CLOSED,
                   "hdc service or client socket closed");

/*********************TSDAEMON************************/
// create TSDAEMON error level error
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_START_FAIL, "Tsdaemon start fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_CLEANPROC_FIRST_GETPID_FAILED, "Tsdaemon first get pid fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_CLEANPROC_KILL_PROCESS_FAILED, "Tsdaemon kill processfail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_CLEANPROC_SECOND_GETPID_FAILED, "Tsdaemon second get pid fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_CLEANPROC_FINAL_FAILED, "Tsdaemon clean process final fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_INIT_STATE_FAILED, "Tsdaemon init state fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_INIT_HDCSERVER_FAILED, "Tsdaemon init hdcserver fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_SEND_HEARTBEAT_FAILED, "Tsdaemon get pid fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_CLEAN_RESOURCE_FAILED, "Tsdaemon clean resource fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_SEND_MSG_FAILED, "Tsdaemon send msg fail");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_AICPU_SD_PROCESS_ABNORMAL, "aicpu_sd process abnormal");
TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_INFO, TDT_TSD_CUSTOM_PROCESS_ABNORMAL, "custom_aicpu_sd process abnormal");

/********************* PPC ****************************/
// create PPC error level error
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_DRIVER_INIT_FAIL, "Init PPC driver fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SERVER_CLIENT_CREATE_FAIL, "Create PPC server or PPC client fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SERVER_CLIENT_DESTORY_FAIL, "Destory PPC server or PPC client fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SERVER_CLOSE, "PPC server is closed");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_GET_SET_MSG_BUFFER_FAIL, "PPC get or set msg buffer fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SESSION_CONNECT_FAIL, "PPC connect is failed");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SESSION_NOT_EXISTED, "PPC session is not existed");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SEND_RECEIVE_MSG_FAIL, "PPC send or receive msg fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_MSG_FREE_FAIL, "PPC msg free fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_ALLOC_MSG_FAIL, "PPC alloc memory for msg fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_MSG_LEN_NOT_MATCH, "PPC message length not match");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_MSG_BUF_NULL, "PPC message buffer is null");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_CLIENT_INVALID_PARAM, "PPC message client invalid param fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SERVER_INVALID_PARAM, "PPC message server invalid param fail");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_CLIENT_RECVDATA_CONTINUE,
                   "PPC message client receive not expected msg continue");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SERVER_CLIENT_SOCKET_CLOSED,
                   "PPC message server receive server or client socket closed msg");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_RECV_MSG_ERROR, "PPC receive msg failed");
TDT_DEF_ERROR_CODE(MODID_PPC, TDT_ERROR, TDT_PPC_SESSION_CLOSE_ERROR, "PPC close session failed");

TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_GET_FILE_STATE_FAIL, "can not get file state");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_OPEN_FILE_FAIL, "can not open file");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_CONTENT_EMPTY, "file content is empty");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_FILE_DESTROYED, "file is destroyed");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_UNABLE_TO_GET_FILE_MEMORY, "fail to get memory for file");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_TYPE_UNSUPPORT, "file type is not supported");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_DIR_IS_NULL, "pointer to dir is null");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_GET_DIR_TREE_ERROR, "can not get the tree of dir");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_CANNOT_OPEN_DIR, "dir cannot be opened");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_CANNOT_DFREE_FILE_MEMORY, "DFree memory of file failed");

TDT_DEF_ERROR_CODE(MODID_TDT_SHUFFLE, TDT_ERROR, TDT_SHUFFLE_SHUFFLE_SIZE_ILLEGAL,
                   "shuffle size is less or equal to 0");
TDT_DEF_ERROR_CODE(MODID_TDT_SHUFFLE, TDT_ERROR, TDT_SHUFFLE_ONLINE_UNIQUE_SEED_ILLEGAL,
                   "online unique seed is equal to 0");
TDT_DEF_ERROR_CODE(MODID_TDT_SHUFFLE, TDT_ERROR, TDT_SHUFFLE_UNABLE_TO_CREATE_SHUFFLE_LIST,
                   "unable to create shuffle list");
TDT_DEF_ERROR_CODE(MODID_TDT_SHUFFLE, TDT_ERROR, TDT_SHUFFLE_ILLEGAL_SHUFFLE_TYPE, "illegal shuffle type");
TDT_DEF_ERROR_CODE(MODID_TDT_SHUFFLE, TDT_ERROR, TDT_SHUFFLE_NOT_INITED, "shuffler has not been inited");

TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SAMPLE_HAS_NO_LABEL, "the sample has no label");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SAMPLE_CANNOT_BE_READ, "the sample cannot be read");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_ILLEGAL_DATATYPE, "illegal data type");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_CREATE_FAILED, "creating prefetcher failed");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_UNABLE_TO_GET_TDTDATAITEM, "fail to get TDTDataItem");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_DATA_QUEUE_IS_CLOSED, "data queue is closed");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_GET_SHUFFLE_RESULT_FAIL, "fail to get shuffle result");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_LABEL_FILE_NOT_INITED, "label file has not been inited");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SAMPLE_FILE_DIR_NOT_INITED,
                   "directory of sample files has not been inited");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_NOT_INITED, "prefetcher in deliver has not been inited");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SHUFFLER_NOT_CREATED,
                   "shuffler in prefetcher has not been created");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SHUFFLED_ITEM_OUT_OF_FILE_LIST,
                   "shuffled item is out of file list");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FAIL_TO_GENERATE_MD5, "fail to generate md5 of data");
TDT_DEF_ERROR_CODE(MODID_CHECKSUM, TDT_ERROR, TDT_CHECKSUM_ILLEGAL_MD5_PARAM, "params to generate md5 is illegal");
TDT_DEF_ERROR_CODE(MODID_CHECKSUM, TDT_ERROR, TDT_CHECKSUM_MD5_INIT_FAILED, "md5_init failed");
TDT_DEF_ERROR_CODE(MODID_CHECKSUM, TDT_ERROR, TDT_CHECKSUM_MD5_UPDATE_FAILED, "md5_update failed");
TDT_DEF_ERROR_CODE(MODID_CHECKSUM, TDT_ERROR, TDT_CHECKSUM_MD5_FINAL_FAILED, "md5_final failed");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_CANNOT_OPEN_CONFIGFILE, "can not open config file");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_PARSE_FILE_FAILED, "parse file failed");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_NO_CHANNEL_DATA,
                   "no channel can be found in config file");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_NO_PARAMETER, "no parameter can be found");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_NO_PARAMETER_ARG,
                   "the argment is not --configfile or stop");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_CREATE_DELIVER_FAILED,
                   "fail to create train data deliver");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_TRAIN_DATA_DELIVER_IS_NULLPTR,
                   "train data deliver in the list is nullptr");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_INIT_FAILED, "train data deliver init failed");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_START_FAILED, "train data deliver start failed");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_CONFIG_FIEL_SYNTAX_ERROR,
                   "config file has syntax error");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_DELIVER_IS_NONE, "no deliver is existed");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_MKDIR_CMD_FAILED, "mkdir cmd failed");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_CP_CMD_FAILED, "cp cmd failed");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_EMPTY_GROUPNAME_IN_MULTI_GROUPS, "empty group_name");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_DUPLICATE_GROUPNAME,
                   "the same group_name already exists");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_DUPLICATE_DEVICE, "the same device already exists");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_ERROR, TDT_TRANSFER_FIND_DEVICE_FAIL, "cannot find device");

TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_WARNING, TDT_SUPERVISOR_INOTIFY_INTERRUPT, "inotify is interrupted");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_UNKOWN_JOB_STATE, "unknow job state");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_ILLEGAL_HEARTBEAT_TIME, "illegal heartbeat time");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_INOTIFY_READ_SIZE_ERROR,
                   "read size of inotify is error");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_INOTIFY_INIT_ERROR,
                   "Initialization of inotify failed");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_CLOSE_INOTIFYFD_FAIL, "Close inotifyFd failed");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_INOTIFY_WATCH_ERROR, "Add watch of inotify failed");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_FAIL_TO_WRITE_PID_FILE, "fail to write pid file");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_HEARTBEAT_FILE_NOT_INITED,
                   "heart beat file has not been inited");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_JOB_COMMAND_FILE_NOT_INITED,
                   "job command file has not been inited");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_JOB_STATE_FILE_NOT_INITED,
                   "job state file has not been inited");
TDT_DEF_ERROR_CODE(MODID_TDT_SUPERVISOR, TDT_ERROR, TDT_SUPERVISOR_FAIL_TO_DEL_JOB_CMD_FILE,
                   "fail to delete job command file");
TDT_DEF_ERROR_CODE(MODID_TDT_TRANSFER, TDT_WARNING, TDT_TRANSFER_FAIL_TO_GET_ENV_VARIABLE,
                   "can not get environment variable");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_ERROR, TDT_MONITOR_INOTIFY_INIT_ERROR, "Initialization of inotify failed");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_ERROR, TDT_MONITOR_INOTIFY_WATCH_ERROR, "Add watch of inotify failed");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_ERROR, TDT_MONITOR_CLOSE_INOTIFYFD_FAIL, "Close inotifyFd failed");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_WARNING, TDT_MONITOR_INOTIFY_READ_SIZE_ERROR,
                   "read size of inotify is not correct");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_WARNING, TDT_MONITOR_UNSUPPORT_CFGITEM, "unsupported config item");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_WARNING, TDT_MONITOR_FAIL_TO_SET_CFGITEM, "can not set local config item");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_ERROR, TDT_MONITOR_READ_FILE_FAIL, "read file fail");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_ERROR, TDT_MONITOR_CONFIG_FILE_FORMAT_ERROR,
                   "config file is incorrectly formatted");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_ERROR, TDT_MONITOR_STRCAT_FAILED, "strcat failed");
TDT_DEF_ERROR_CODE(MODID_TDT_MONITOR, TDT_ERROR, TDT_MONITOR_CREATE_CONFIG_FILE_FAIL,
                   "create ConfigFile pointer failed");

TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MAP_BUFFER_ERROR, "host buffer map to device failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_ALLOC_BUFFER_FAILED, "memory pool alloc buffer failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_DATA_SIZE_WRONG, "Input datasize is wrong");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_FREE_HDC_BUFFER_FAILED, "memory pool free buffer failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_INVALID_VALUE, "invalid parameter");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_NO_USEFUL_MEMORY, "no usable memory in memory pool");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MESSAGE_NULL, "recv msg is null");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_SENDMSG_FAILED, "send msg failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_POOL_STOPPED, "mempool has stopped");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_HDC_MEMORY_ADDR_NOT_ALIGN, "buffer not aligned");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_POOL_INITED, "memory pool has inited");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_POOL_GET_NULL, "mempool not exist");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_POOL_NOT_EXISTED, "mempool not exist");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_RECOVER_DATA_FAILED, "Recover recv data failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_STATUS_ERROR, "Memory status error");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_POOL_UPDATE_FAILED, "update memory pool status failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_POOL_RESIZE_FAILED, "resize memory pool status failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_EXCEED_MAX_THREAD, "thread size is too large");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_WARNING, TDT_WARNING_SET_THREAD_NAME_FAILED, "rename thread failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_WARNING, TDT_WRONG_PRIORITY, "priority is invalid");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_WARNING, TDT_JOIN_TASK_ERROR, "join task failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_WARNING, TDT_NULL_FUNC, "func is null");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_WARNING, TDT_INIT_FAIL, "sear/dear init failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_WARNING, TDT_EXISTED_FUNC, "func has already existed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_DESTROY_FAILED, "mempool destroy failed");
TDT_DEF_ERROR_CODE(MODID_MEM_POOL, TDT_ERROR, TDT_MEMORY_DATA_TYPE_FACTORY_MAKE_SHARED_FAILED,
                   "data type factory make shared failed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_TDTSEVER_ACCEPT_FAILED, "tdt server accept hdc session failed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_CHANNEL_DO_NOT_EXIST, "channel do not exist");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_NULL_POINTER_MSG, "message is null");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_TRAN_UNKNOWN_RSP, "transcation status error");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_TRAN_TIMEOUT, "transcation time out");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_TRAN_NOT_EXIST, "transcation requst id is not exist");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_TRAN_ID_GEN_ERROR, "transcation generateid failed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_SEND_CHANNEL_FAILED, "send channel info failed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_SEND_CHANNEL_TIMEOUT, "send channel info time out");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_INFO, TDT_QUEUE_STOPPED, "queue has been stopped");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_INFO, TDT_QUEUE_POP_FAILED, "failed to pop data from queue");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_INFO, TDT_QUEUE_PUSH_FAILED, "failed to push data from queue");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_QUEUE_CREATE_FAILED, "queue create fail");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_QUEUE_NOT_FIND, "queue not find");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_QUEUE_FULL, "queue is full");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_QUEUE_EMPTY, "queue is empty");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_DATA_ENTO_CP_FAILED, "enqueue to computer process failed");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_STOP_CP_QUEUE_FAILED, "stop computer process queue failed");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_RECV_MSG_NO_CHANNEL_INFO_ERROR, "no channel in first msg");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_RECV_MSG_MD5_WRONG, "md5 of recv msg is wrong");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_RECV_MSG_CHECKSUM_WRONG_ERROR, "checksum of recv msg is wrong");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_RECV_MSG_FAIL_TO_GENERATE_MD5, "md5 of recv msg is wrong");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_RECV_MSG_SEQUENCE_ERROR, "sequence recv msg is wrong");
TDT_DEF_ERROR_CODE(MODID_TDT_SERVER, TDT_ERROR, TDT_SERVER_MEMORY_COPY_FAILED, "memory copy failed");
TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_CHANNEL_HAS_NO_SESSION_ERROR, "channel has no session");
TDT_DEF_ERROR_CODE(MODID_HDC_CLIENT, TDT_ERROR, TDT_HDC_CLIENT_INIT_ERROR, "hdc client init error");
TDT_DEF_ERROR_CODE(MODID_HDC_CLIENT, TDT_ERROR, TDT_HDC_CLIENT_CREATE_SESSION_ERROR, "hdc client create error");
TDT_DEF_ERROR_CODE(MODID_HDC_CLIENT, TDT_ERROR, TDT_HDC_CLIENT_DO_NOT_EXIST, "hdc client do not exist");
TDT_DEF_ERROR_CODE(MODID_HDC_CLIENT, TDT_ERROR, TDT_HDC_CLIENT_DESTROY_ERROR, "hdc server destroy error");
TDT_DEF_ERROR_CODE(MODID_HDC_CLIENT, TDT_ERROR, TDT_HDC_CLIENT_CLOSED, "hdc client has been closed");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_BIND_CPUCORE_FAILED, "thread function bind cpu core failed");
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDC_SRV_CLOSED, "hdc server has been closed");
TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_OPEN_FAILED, "tsd client open failed");
TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_CLOSE_FAILED, "tsd client close failed");
TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_UPDATE_PROFILING_FAILED,"tsd client update profiling failed");
TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_INTERFACE_NOT_SUPPORT, "tsd client func not support");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILELIST_NOT_EXIST, "tdt filelist open failed");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SAMPLE_FILE_NOT_FOUND, "tdt sample file is empty");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILE_OPEN_FAIL, "tdt open sample file fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILE_STAT_FAIL, "tdt stat sample file fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILE_MMAP_FAIL, "tdt mmap sample file fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILE_UNMAP_FAIL, "tdt unmap sample file fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILE_CLOSE_FAIL, "tdt close sample file fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILE_PARSE_FAIL, "tdt parse sample file fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_CRC32_SIZE_FAIL, "tdt crc32 of size mismatch");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_CRC32_DATA_FAIL, "tdt crc32 of data mismatch");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_DATA_QUEUE_CLOSED, "tdt prefetch data queue closed");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_MAP_INSERT_FAILED, "map insert fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_INITIALIZE_FAILED, "prefetch init fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_INVALID_FILELIST_LINE, "invalid filelist line");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_STRINGSTREAM_TO_VALUE_FAILED, "string to value fail");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_LIST_ID_OFFSET_LENGTH_POSITIVE_INTEGER_FAILED,
                   "value positive integer fail");
TDT_DEF_ERROR_CODE(MODID_TDT_SHUFFLE, TDT_ERROR, TDT_SHUFFLE_ILLEGAL_SHUFFLE_PARAM, "Illegal shuffle parameter");
TDT_DEF_ERROR_CODE(MODID_TDT_SHUFFLE, TDT_ERROR, TDT_FILE_SHUFFLER_CREATE_FAILED, "Create file shuffler fail");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_UPLOADER_CREATE_FAILED, "Create uploader fail");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FILE_DOWNLOADER_CREATE_FAILED, "Create downloader fail");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FOLDER_CANNOT_BE_CREATED, "folder cannot been created");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_CANNOT_GET_STAT_OF_FOLDER, "cannot get stat of folder");
TDT_DEF_ERROR_CODE(MODID_TDT_FILE, TDT_ERROR, TDT_FOLDER_IS_FILE, "folder is a file");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_OBS_CONFIG_INFORMATION_FAIL, "OBS configuration fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_OBS_CALLBACK_ARGUMENT_FAIL, "OBS callback argument fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_OBS_DOWNLOAD_CREATE_THREAD_FAILED,
                   "OBS download create thread fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_OBS_DOWNLOAD_FILE_FAIL, "OBS download file fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_OBS_DOWNLOAD_INIT_FAIL, "OBS download init fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_OBS_DOWNLOAD_METADATA_FAIL, "OBS download metadata fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_OBS_LIST_BUCKET_OBJECTS_FAIL, "OBS list bucket fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_MEMORY_MEMCPY_FAILED, "tdt securec memcpy fail");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_MEMORY_MEMSET_FAILED, "tdt securec memset fail");
// TDT HOST
TDT_DEF_ERROR_CODE(MODID_TDT_HOST, TDT_ERROR, TDT_HOST_INIT_FAILED, "tdt host init failed");
TDT_DEF_ERROR_CODE(MODID_TDT_HOST, TDT_ERROR, TDT_HOST_CHANNEL_NAME_EMPTY, "channel name is empty");
TDT_DEF_ERROR_CODE(MODID_TDT_HOST, TDT_ERROR, TDT_HOST_ALLOCATE_MEMORY_FAILED, "allocate memory failed");
TDT_DEF_ERROR_CODE(MODID_TDT_HOST, TDT_ERROR, TDT_HOST_MEMORY_COPY_FAILED, "memory copy failed");
TDT_DEF_ERROR_CODE(MODID_TDT_HOST, TDT_WARNING, TDT_HOST_UNABLE_GET_TDTDATAELEM, "can not get data element");
TDT_DEF_ERROR_CODE(MODID_TDT_HOST, TDT_WARNING, TDT_HOST_PUSH_NOT_INIT, "push data but not init");

TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_TUNING_DATA_TRANSFER_INIT_FAILED,
                   "failed to init the channel of tuning-data");

TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_TUNING_DATA_RECEIVE_CHECK_PARA_ERROR, "the index is error");

TDT_DEF_ERROR_CODE(MODID_TDT_CLIENT, TDT_ERROR, TDT_TUNING_DATA_TRANSFER_PARAMETER_ERROR, "the parameter is error");
TDT_DEF_ERROR_CODE(MODID_SVM, TDT_ERROR, TDT_SVM_INIT_FAILED, "SVM driver init failed");
TDT_DEF_ERROR_CODE(MODID_SVM, TDT_ERROR, TDT_SVM_FREE_PIN_FAILED, "SVM driver free host pin memory failed");
TDT_DEF_ERROR_CODE(MODID_SVM, TDT_ERROR, TDT_SVM_FREE_SVM_FAILED, "SVM driver free device svm memory failed");
TDT_DEF_ERROR_CODE(MODID_SVM, TDT_ERROR, TDT_SVM_ADD_BUFFER_MAP_FAILED, "add svm buffer info to map failed");
#endif  // INC_TDT_STATUS_H_
